#pragma once

#include <windows.h>

namespace platform {

class Condition {
	HANDLE _handle;

public:
	inline Condition(void) {
		_handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);
	}

	inline Condition(const Condition &c) {
		::DuplicateHandle(::GetCurrentProcess(), c._handle, ::GetCurrentProcess(), &_handle, 0, FALSE, DUPLICATE_SAME_ACCESS);
	}

	~Condition(void) { ::CloseHandle(_handle); }


public:
	inline HANDLE getWaitHandle(void) { return _handle; }

	inline void set(void) { ::SetEvent(_handle); }

	inline void wait(void) { ::WaitForSingleObject(_handle, INFINITE); }
};

}  // ena namespace